// pages/car/end/end.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {

	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {

		wx.request({
			url: 'http://www.51macc.com:8080/Mattrio/SelectCar/Nameofsales',
			method: 'POST',
			header: {
				"Content-Type": "application/x-www-form-urlencoded;"
			},
			data: {
				userid: 'dae3956e-e61c-4768-9308-dd9e8841fa25',
				VehicleName: options.VehicleName,
				year: options.year,
				Manufacture: options.Manufacture,
				car_type: 1
			},
			success: (e) => {
				console.log(e)
				this.setData({
					year: options.year,
					Manufacture: options.Manufacture,
					Nameofsales: options.VehicleName,
					data: e.data
				})
			}
		})
	},
	nav(env){
		wx.getStorage({
			key:'uid',
			success:(e)=>{
				wx.request({
					url:getApp().globalData.http+'action=addnewcars&uid='+e.data.uid+'&manufactureCn='+
					this.data.Manufacture+'&vehicleNameCn='+this.data.Nameofsales+'&vehicleSeriesNameCn='+env.currentTarget.dataset.id
					+'&vehicleOfYear='+this.data.year,
					success:(e)=>{
						console.log(e)
						if(e.data.code==1){
							wx.navigateBack({
								delta:4
							})
						}else{
							wx.showToast({
								title:e.data.msg,
								icon:'none'
							})
						}
					}
				})
			}
		})
	}
})
